package com.w.proxy.player.testplayer;

import com.w.proxy.player.api.IDotaPlayer;
import com.w.proxy.player.api.IPlayer;
import com.w.proxy.player.impl.LoLPlayer;
import com.w.proxy.player.playerproxy.aop.*;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;


public class TestAop {

    @Test
    public void test() {
        IPlayer iPlayer = new LoLPlayer();
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setTarget(iPlayer);
//        proxyFactory.addAdvice(new LoLPlayerBeforeAdvice());
//        proxyFactory.addAdvice(new LoLPlayerAfterAdvice());
//
//        proxyFactory.addAdvice(new LoLPlayerAroundAdvice());

        //proxyFactory.addAdvice(new LoLPlayerThrowAdvice());

        proxyFactory.addAdvice(new LoLPlayerIntroductionAdvice());


        //loLPlayer.throwsTest();
        // 要使用引入增强
        proxyFactory.setInterfaces(IDotaPlayer.class);
        proxyFactory.setProxyTargetClass(true);


        LoLPlayer loLPlayer = (LoLPlayer) proxyFactory.getProxy();

        IDotaPlayer iDotaPlayer = (IDotaPlayer) loLPlayer;

        iDotaPlayer.dota();
    }
}
